﻿using System;
using System.Collections.Generic;
using System.Text;
using YouHP.Utility;
using YouHP.BLL;
using YouHP.Model;

namespace YouHP.Pages.User
{
    public class Logout:BasePage
    {
        protected UserInfo user = null ;

        protected override void ShowPage()
        {
            base.ShowPage();
            HandleCommon();

            PageTitle = "用户退出";
            user = UserBLL.Instance.GetUserInfo(UserData.Id);
            UserData.Id = -1; //退出

            if (user != null)   //防止非法的cookie
            {
                //更新登录状态
                UserBLL.Instance.UpdateUserLoginState(user.Id, 0);

                CookiesTools.ClearUserCookie();
                //CookiesTools.WriteUserNameCookie(user.UserName);    //将本次登陆的用户名写入cookie，方便下次用户的输入
            }



            SetUrl("/Index.aspx");
            SetMetaRefresh();

            AddMsgLine("退出成功，将自动返回首页！");
        }

        protected void HandleCommon()
        {
            this.AddLocation("用户退出", "/User/Logout.aspx");
        }

    }
}
